$(function () {
    $("#ganttChart").ganttView({
        // showWeekends: true,
        data: ganttData,
        hoursOfDay: ['0', '6', '12', '18'],
        // hoursOfDay: ['0', '1', '2', '3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23'],
        behavior: {
            onClick: function (data,el) {
                let popEl = $("<div class='popWrap'>我是弹出内容</div>")
                $('#'+data.id).append(popEl);
                var msg = "click事件:" + JSON.stringify(data);
                $("#eventMessage").text(msg);
            },
            onResize: function (data) {
                var msg = "resize事件:" + JSON.stringify(data);
                $("#eventMessage").text(msg);
            },
            onDrag: function (data) {
                // console.log(data);
                var msg = "drag事件:" + JSON.stringify(data);
                $("#eventMessage").text(msg);
            }
        }
    });
    $("#submit").click(function () {
        $("#ganttChart").ganttView("getDatas", function (datas) {
            console.log(datas);
            $("#submitData").text(JSON.stringify(datas));
        });
    });

    $("#ganttChart").on("click",".ganttview-block",function (ev) {
        console.log(ev);
        $("#popMsg").css({
            "display":"block",
            "left":ev.clientX+"px",
            "top":ev.clientY+"px"
        })
    });
    $("body").click(function (e) {
        if (!$(e.target).closest("#popMsg").length&&!$(e.target).closest(".ganttview-block").length) {
            $("#popMsg").hide();
        }
    });
});


